Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that create script installs same version of starter files and kit #1621

Merged
merged 5 commits into from
Sep 27, 2022

Conversation

lfdebrux
Copy link
Member

@lfdebrux lfdebrux commented Sep 26, 2022

Splits the process of creating a new prototype into two with copying the starter files done after the version of the kit to be used has been installed. This makes sure the user doesn't end up with starter files that require features not available to the installed kit version. This is similar to what the create-react-app tool does [1].

Fixes #1616.

@lfdebrux lfdebrux requested a review from a team September 26, 2022 11:03
@lfdebrux lfdebrux changed the base branch from main to v13 September 26, 2022 11:04
@lfdebrux lfdebrux force-pushed the ldeb-fix-issue-1616 branch 2 times, most recently from 99874c8 to 712c731 Compare September 26, 2022 11:25
Splits the process of creating a new prototype into two with copying the
starter files done after the version of the kit to be used has been
installed. This makes sure the user doesn't end up with starter files
that require features not available to the installed kit version. This
is similar to what the create-react-app tool does [[1]].

[1]: https://github.com/facebook/create-react-app/blob/main/packages/create-react-app/createReactApp.js
bin/cli Outdated
// as possible into stage two; stage one should ideally be able to install
// any future version of the kit.

const stage = additionalOptions[0] === '--' ? 'two' : 'one'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than having the stage one and two both called create can we call stage one create and stage two generate-starter-files (or something similar)?

Also, I realised we had a problem with the cli args and I've created a util for reading them. Feel free to bring these changes into your branch if it helps (if you do I'll close my PR) https://github.com/alphagov/govuk-prototype-kit/pull/1622/files

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than having the stage one and two both called create can we call stage one create and stage two generate-starter-files (or something similar)?

Yeah we can do that. Do we want that stage two command to be documented and usable independently?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit f6f063c does this, if you're happy with the result I'll squash it into the parent.

// `init` is stage two of the install process (see above), it should be
// called by `create` with the correct arguments.

if (additionalOptions[0] !== '--') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for the double-hypen? Is it just to make sure people don't use it by mistake?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, exactly that 😁

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering whether we should be more specific with it - something like --internal-use-only ... selfishly for the parser I've just created I'd love it if it was a key and value pair e.g. ---internal-use=true.

If you think it's best as just -- we can support that separately to the parser.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering whether we should be more specific with it

I'm not sure there is any need to be more specific, using -- to indicate internal arguments is a pattern I've encountered several times before in the past.

If you think it's best as just -- we can support that separately to the parser.

Yeah, I don't think it needs to go into the parser, this code can read the arguments straightforwardly from process.argv and assume that the caller has supplied them correctly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I'm happy with that.

@lfdebrux lfdebrux merged commit 1f1802a into v13 Sep 27, 2022
@lfdebrux lfdebrux deleted the ldeb-fix-issue-1616 branch September 27, 2022 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create script can install different version of starter files to version of kit
2 participants